/**
 * 返回非负数字x中从右循环n比特
 */

#include <stdio.h>

unsigned rightrot(unsigned x, int n);

int main() {
    unsigned x = 0x0fffffff;
    int n = 4;
    printf("0x%x\n", rightrot(x, n));

    return 0;
}

// unsigned int 32位
unsigned rightrot(unsigned x, int n) {
    return (x >> n) | ((x & ((1 << n) - 1)) << (32 - n));
}
